<?php
declare (strict_types=1);

namespace app\api\controller;

use think\Response;
use app\common\tool\Result;
use app\common\model\MakePlace as MakePlaceModel;

class MakePlace extends Base
{
    /**
     * @return Response
     * 原点 2023年4月4日11:16:41 获取申请信息
     */
    public function index(): Response
    {
        try {
            return Result::success('success',
                MakePlaceModel::where('uid', $this->user->id)->where(['is_del'=>0])
                    ->field('id,title,mobile,status,create_time')
                    ->order('id','desc')
                    ->find()
            );
        } catch (\Exception $e) {
            return Result::fail($e->getMessage());
        }
    }

    /**
     * @return Response
     * 原点 2023年4月4日11:04:35 申请分销商
     */
    public function save(): Response
    {
        try {
            $param = $this->request->param();
            $this->validate($param, 'MakePlace');
            return Result::fastReturn(MakePlaceModel::add($param, $this->user));
        } catch (\Exception $e) {
            return Result::fail($e->getMessage());
        }
    }
}

